const fs = require('fs');
let path="./jsonData/";
const jsonResponse = ()=>function(req, res, next){
    let filename = req.baseUrl+".json";
    filename = path+(filename.replace(/^\/*/,''));
    if(fs.existsSync(filename)){
        var data = fs.readFileSync(filename, 'utf8');
        let content = data.toString();
        res.status(200).send(content);
    }else{
        next();
    }
}
module.exports = {jsonResponse};
